import './test'
import './style/index.less'
import GameControl from './common/gameControl'

const gameControl = new GameControl()
// setInterval(() => {
//     console.log(gameControl.direction)
// }, 1000)

class T  {
    id?: number;
    name: string
    age: number
    constructor(name: string,age: number) {
        this.name = name
        this.age = age
    }
}

interface BaseCURD<T> {
    data:Array<T>
    add(t:T):T
    get(id:number):T
}

class User implements BaseCURD<T> {
   data:Array<T> = []
   add(user:T):T{
       user.id = Number(Math.random().toFixed(4))
       this.data.push(user)
     return user
   }
   get(id:number):T{
      const obj = this.data.find(item=>item.id === id)
      return obj as T
   }
}

const dataList = new User()
dataList.add(new T('张三',18))
console.log(dataList)